package Classes.PersonExtends;

import Utils.GameConfig;

public class PersonThread extends Thread {
	
	Person person;
	int sleepSpan=40;
	
	public PersonThread(Person person){
		
		this.person=person;
		
	}

	
	public void run(){
		while(true){
			if((person.detaX!=0||person.detaY!=0)){
				person.addActPix(GameConfig.PERSONMOVEPIXELS);
				person.detaMove+=GameConfig.PERSONMOVEPIXELS;
				if(person.detaMove>=GameConfig.BITSIZE){
					person.detaMove=0;
					person.x+=person.detaX;
					person.y+=person.detaY;
					person.detaX=0;
					person.detaY=0;
					person.isDoSomething=false;
				}
			}
			
			try{
				Thread.sleep(GameConfig.PERSONMOVETIMESPAN);
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	}
		
}
